package cn.edu.zhku.citrusmonitor.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DirectoryBrokenUtil {
	// 根据日期打乱文件
	public static String directoryBrokenByDate(File storeDirectory,String filename) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String dateDirectory = sdf.format(new Date());
		File file = new File(storeDirectory,dateDirectory);
		if(!file.exists()){
			file.mkdirs();
		}
		return dateDirectory;
	}
	// 根据哈希打乱文件
	public static String directoryBrokenByFile(File storeDirectory,String filename) {
		int hashCode = filename.hashCode();	
		String code = Integer.toHexString(hashCode);	
		String childDirectory = code.charAt(0)+File.separator+code.charAt(1);
		File file = new File(storeDirectory,childDirectory);
		if(!file.exists()){
			file.mkdirs();
		}
		return childDirectory;
	}
}
